package com.zrt.springboot.utils;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import java.util.LinkedList;

public class LimitedQueue<E> extends LinkedList<E> {
    private static final long serialVersionUID = 1L;
    private final int size;

    public LimitedQueue(int size) {
        this.size = size;
    }

    @Override
    public boolean add(E o) {
        super.add(o);
        while (size() > size) {
            super.remove();
        }
        return true;
    }
}
